from rest_framework import serializers
from goods.models import SpecificationOption,SPUSpecification

#1,spec options 序列化器
class SpecOptionsSerializer(serializers.ModelSerializer):

    #1,重写spec,spec_id
    spec = serializers.StringRelatedField(read_only=True)
    spec_id = serializers.IntegerField()

    class Meta:
        model = SpecificationOption
        fields = "__all__"

#2,spec list信息序列化器
class SpecListSerializer(serializers.ModelSerializer):
    class Meta:
        model = SPUSpecification
        fields = ["id","name"]